package com.tuling.designpattern.prototype.demo01;

import java.util.Date;

/**
 * @author 林瑞涛
 * @desc
 * @date 2021年07月14日 20:16
 */
public class BCopy {

    public static void main(String[] args) throws CloneNotSupportedException {
        //原型对象v1
        Date date = new Date();
        Video v1 = new Video("原型模式", date);
        Video v2 = (Video) v1.clone();
        System.out.println("v1=>" + v1);
        System.out.println("v2=>" + v2);

        System.out.println("======================");
        date.setTime(2114422);
        System.out.println("v1=>" + v1);
        System.out.println("v2=>" + v2);


        //v1 克隆v2
        //Video v2 = new Video("原型模式", date);
        /*Video v2 = (Video) v1.clone();
        System.out.println("v2=>" + v2);
        System.out.println("v2=>hash:" + v2.hashCode());
        v2.setName("原型模式复制");
        System.out.println(v2);*/
    }
}
